<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      Array.prototype.myiterator = function () {
        //计时器 记录当前下标
        var index = 0;
        return {
          next:  () => {
            if (index < this.length) {
              return {
                value: this[index++],
                done: false,
              };
            } else {
              return {
                value:undefined,
                done: true,
              };
            }
          },
        };
      };

      var arr = ["张三", "李四", "王五"];

      var myi = arr.myiterator(); // 自定义 方法

      // myi.next()
      // myi.next()
      // myi.next()
      // myi.next()

        // var myi = arr[Symbol.iterator]();
      console.log(myi.next());
      console.log(myi.next());
      console.log(myi.next());
    //   console.log(myi.next());
    </script>
  </body>
</html>
